package com.elminster.entity.base;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * Detail entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "detail", catalog = "test")
public class Detail implements java.io.Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    // Fields
    private Integer id;
//    private Integer catalogId;
    private Integer ownerId;
    private Date occurTime;
    private Double account;
    private Date updateDate;
    private Catalog catalog;

    // Constructors

    /** default constructor */
    public Detail() {
    }

    /** full constructor */
    public Detail(Catalog catalog, Integer ownerId, Date occurTime,
            Double account, Date updateDate) {
        this.catalog = catalog;
        this.ownerId = ownerId;
        this.occurTime = occurTime;
        this.account = account;
        this.updateDate = updateDate;
    }

    // Property accessors
    @Id
    @GeneratedValue
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
    
    @ManyToOne()
//    @Cascade(value={CascadeType.SAVE_UPDATE})
    @JoinColumn(name="catalog_id")
    public Catalog getCatalog() {
        return this.catalog;
    }
    
    public void setCatalog(Catalog catalog) {
        this.catalog = catalog;
    }

//    @Column(name = "catalog_id", nullable = false)
//    public Integer getCatalogId() {
//        return this.catalogId;
//    }
//
//    public void setCatalogId(Integer catalogId) {
//        this.catalogId = catalogId;
//    }

    @Column(name = "owner_id", nullable = false)
    public Integer getOwnerId() {
        return this.ownerId;
    }

    public void setOwnerId(Integer ownerId) {
        this.ownerId = ownerId;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "occur_time", nullable = false, length = 10)
    public Date getOccurTime() {
        return this.occurTime;
    }

    public void setOccurTime(Date occurTime) {
        this.occurTime = occurTime;
    }

    @Column(name = "account", nullable = false, precision = 15)
    public Double getAccount() {
        return this.account;
    }

    public void setAccount(Double account) {
        this.account = account;
    }

    @Temporal(TemporalType.DATE)
    @Column(name = "update_date", nullable = false, length = 10)
    public Date getUpdateDate() {
        return this.updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
    }
}